import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import system from '@/api/system/system'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  // {
  //   path: '/auth-redirect',
  //   component: () => import('@/views/login/auth-redirect'),
  //   hidden: true
  // },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/SysSetting/dashbord',
    name: 'Home',
    meta: { title: '系统管理', icon: 'el-icon-s-help' },
    children: [
      {
        path: '/SysSetting/dashbord',
        name: 'SysSetting',
        component: () => import('@/views/dashboard/index'),
        meta: { title: '控制面板', affix: true, noCache: true, name: '1' }
      },
      {
        path: '/sysSetting/index',
        name: 'SysSetting',
        component: () => import('@/views/system/sysSetting'),
        meta: { title: '系统设置', icon: 'icon-xitongshezhi', name: '1' }
      },
      {
        path: 'admin',
        name: 'Admin',
        component: () => import('@/views/system/account/index'),
        meta: { title: '管理员权限', icon: 'icon-guanliyuanquanxian', name: '1' },
        children: [
          {
            path: '/Admin/index',
            name: 'Admin',
            component: () => import('@/views/system/account/admin'),
            meta: { title: '管理员管理', icon: 'table', name: '1' }
          },
          {
            path: '/Role/index',
            name: 'Role',
            component: () => import('@/views/system/account/role'),
            meta: { title: '角色管理', icon: 'tree', name: '1' }
          }
        ]
      },
      {
        path: '/Attachment/index',
        name: 'Attachment',
        component: () => import('@/views/system/attachment'),
        meta: { title: '附件管理', icon: 'icon-fujianguanli', name: '1' }
      },
      {
        path: 'record',
        name: 'record',
        component: () => import('@/views/system/record/index'),
        meta: { title: '日志管理', icon: 'user' },
        children: [
          {
            path: '/AdminLoginLog/index',
            name: 'LoginLog',
            component: () => import('@/views/system/record/loginLog'),
            meta: { title: '登录日志', icon: 'table', name: '1' }
          },
          {
            path: '/AdminOptLog/index',
            name: 'OperationLog',
            component: () => import('@/views/system/record/operationLog'),
            meta: { title: '操作日志', icon: 'tree', name: '1' }
          }
        ]
      },
      {
        path: '/RecycleBin/index',
        name: 'RecycleBin',
        component: () => import('@/views/system/recycleBin'),
        meta: { title: '回收站管理', icon: 'icon-huishouzhanguanli', name: '1' }
      },
      {
        path: '/Database/index',
        name: 'Database',
        component: () => import('@/views/system/database'),
        meta: { title: '数据库备份', icon: 'icon-shujukubeifen', name: '1' }
      }
    ]
  },
  {
    path: '/website',
    component: Layout,
    // redirect: '/SysSetting/dashbord',
    name: 'webiste',
    meta: { title: '网站管理', icon: 'dashboard' },
    children: [
      {
        path: '/WebsiteSetting/index',
        name: 'WebsiteSetting',
        component: () => import('@/views/site/websiteSetting'),
        meta: { title: '网站基本设置', icon: 'icon-wangzhanjibenshezhi', name: '32' }
      },

      {
        path: 'mould',
        component: () => import('@/views/site/websiteTemp/index'),
        meta: { title: '网站模板管理', icon: 'icon-wangzhanmobanguanli', name: '32' },
        alwaysShow: true,
        children: [
          {
            path: '/TempleteLibrary/index',
            name: 'TemplateLibrary',
            component: () => import('@/views/site/websiteTemp/templateLibrary'),
            meta: { title: '模板库', name: '32' }
          },
          {
            path: '/Theme/index',
            name: 'Theme',
            component: () => import('@/views/site/websiteTemp/mould'),
            meta: { title: '模板管理', name: '32' }
          },
          {
            path: '/Theme/files',
            name: 'files',
            component: () => import('@/views/site/websiteTemp/components/files'),
            hidden: true,
            meta: { title: '所有文件', guidePath: true, jumpPath: '/Theme/index', name: '32' }
          },
          {
            path: '/Theme/tempFiles',
            name: 'tempFiles',
            component: () => import('@/views/site/websiteTemp/components/tempFiles'),
            meta: { title: '模板文件', guidePath: true, jumpPath: '/Theme/index', name: '32' }
          }
        ]
      },
      {
        path: 'content',
        name: 'Content',
        component: () => import('@/views/site/index'),
        meta: { title: '内容管理', icon: 'icon-neirongguanli', name: '32' },
        children: [
          {
            path: '/Module/index',
            name: 'Model',
            component: () => import('@/views/site/content/contentModel/index'),
            meta: { title: '内容模型', name: '32' }
          },
          {
            path: 'modelField',
            name: 'modelField',
            hidden: true,
            component: () => import('@/views/site/content/contentModel/field'),
            meta: { title: '模型字段', guidePath: 'true', jumpPath: '/Module/index', name: '32' }
          },
          {
            path: '/Category/index',
            name: 'Category',
            component: () => import('@/views/site/content/column'),
            meta: { title: '栏目管理', name: '32' }
          },
          {
            path: '/addColumn',
            name: 'addColumn',
            component: () => import('@/views/site/content/addColumn'),
            meta: { title: '添加栏目', guidePath: 'true', jumpPath: '/Category/index', name: '32' }
          },
          {
            path: '/updateColumn',
            name: 'updateColumn',
            component: () => import('@/views/site/content/updateColumn'),
            meta: { title: '编辑栏目', guidePath: 'true', jumpPath: '/Category/index', name: '32' }
          },
          {
            path: '/Content/index',
            name: 'Content',
            component: () => import('@/views/site/content/columnContent/content'),
            meta: { title: '栏目内容管理', name: '32' }
          },
          {
            path: '/ColumnInfo',
            name: 'ColumnInfo',
            component: () => import('@/views/site/content/columnContent/info'),
            meta: { title: '栏目内容', guidePath: 'true', jumpPath: '/Content/index', name: '32' }
          },
          {
            path: '/addContent',
            name: 'addContent',
            component: () => import('@/views/site/content/columnContent/add'),
            meta: { title: '新增内容', guidePath: 'true', jumpPath: '/Content/index', name: '32' }
          },
          {
            path: '/updateContent',
            name: 'updateContent',
            component: () => import('@/views/site/content/columnContent/update'),
            meta: { title: '编辑内容', guidePath: 'true', jumpPath: '/Content/index', name: '32' }
          },
          {
            path: '/Tag/index',
            name: 'Tag',
            component: () => import('@/views/site/content/tag'),
            meta: { title: '标签管理', name: '32' }
          },
          {
            path: '/ContentTag/index',
            name: 'ContentTag',
            component: () => import('@/views/site/content/tagBuild'),
            meta: { title: '标签生成器', name: '32' }
          }

          // {
          //   path: 'page',
          //   name: 'page',
          //   component: () => import('@/views/site/content/page'),
          //   meta: { title: '页面管理' }
          // },
          // {
          //   path: 'article',
          //   name: 'Article',
          //   component: () => import('@/views/site/content/index'),
          //   meta: { title: '文章模块' }
          // },
          // {
          //   path: 'product',
          //   name: 'Product',
          //   component: () => import('@/views/site/content/product'),
          //   meta: { title: '产品模块' }
          // }
        ]
      },
      {
        path: '/Server/index',
        name: 'Server',
        component: () => import('@/views/site/server'),
        meta: { title: '域名服务器管理', name: '32' }
      },
      {
        path: '/Website/index',
        name: 'Website',
        component: () => import('@/views/site/site'),
        meta: { title: '网站列表', icon: 'icon-zhandianliebiao', name: '32' }
      },
      {
        path: '/NavCate/index',
        name: 'NavCate',
        component: () => import('@/views/site/menu/index'),
        meta: { title: '前台菜单管理', icon: 'icon-qiantaicaidanguanli', name: '32' }
      },
      {
        path: '/SlideCate/index',
        name: 'SlideCate',
        component: () => import('@/views/site/slide/index'),
        meta: { title: '幻灯片管理', icon: 'icon-huandengpianshezhi', name: '32' }
      }
    ]
  },

  {
    path: '/Inquiry/index',
    component: Layout,
    // redirect: '/stats/index',
    name: 'Inquiry',
    meta: { title: '询盘管理', icon: 'el-icon-s-help' },
    children: [
      {
        path: '/Inquiry/index',
        name: 'Inquiry',
        component: () => import('@/views/Inquiry/list'),
        meta: { title: '询盘列表', icon: 'icon-xunpanliebiao', name: '86' }
      },
      {
        path: '/InquiryCate/index',
        name: 'InquiryCate',
        component: () => import('@/views/Inquiry/inquiryCategory/index'),
        meta: { title: '询盘分类', icon: 'icon-xunpanfenlei', name: '86' }
      },
      // {
      //   path: 'field',
      //   name: 'field',
      //   component: () => import('@/views/Inquiry/field'),
      //   meta: { title: '询盘表单字段', icon: 'tree' }
      // },
      {
        path: '/InquiryEmail/index',
        name: 'InquiryEmail',
        component: () => import('@/views/Inquiry/inbox'),
        meta: { title: '询盘收件箱', icon: 'icon-xunpanshoujianxiang', name: '86' }
      }
      // {
      //   path: 'form',
      //   name: 'form',
      //   component: () => import('@/views/Inquiry/form'),
      //   meta: { title: '表单管理', icon: 'tree' }
      // }
    ]
  },
  {
    path: '/market',
    component: Layout,
    redirect: '/market/seo',
    name: 'Market',
    meta: {
      title: '营销管理',
      icon: 'nested'
    },
    children: [
      {
        path: '/index',
        component: () => import('@/views/market/index'), // Parent router-view
        name: 'Index',
        meta: { title: 'SEO', icon: 'icon-SEO', name: '98' },
        children: [
          {
            path: '/Keyword/index',
            component: () => import('@/views/market/seo/keyWords/keyWords'),
            name: 'keyWords',
            meta: { title: '关键词管理', name: '98' }
          },
          // {
          //   path: '/addKeyWords',
          //   component: () => import('@/views/market/seo/keyWords/addKeyWords'),
          //   name: 'addKeyWords',
          //   meta: { title: '添加关键词', guidePath: 'true', jumpPath: '/Keyword/index' }
          // },
          // {
          //   path: '/updateKeyWords',
          //   component: () => import('@/views/market/seo/keyWords/updateKeyWords'),
          //   name: 'updateKeyWords',
          //   meta: { title: '编辑关键词', guidePath: 'true', jumpPath: '/Keyword/index' }
          // },
          // {
          //   path: '/keyWordsInfo',
          //   component: () => import('@/views/market/seo/keyWords/keyWordsInfo'),
          //   name: 'keyWordsInfo',
          //   meta: { title: '关键词详情', guidePath: 'true', jumpPath: '/Keyword/index' }
          // },
          {
            path: '/InnerChart/index',
            component: () => import('@/views/market/seo/innerLink'),
            name: 'InnerChart',
            meta: { title: '内链管理', name: '98' }
          },
          {
            path: '/Advertisement/index',
            component: () => import('@/views/market/seo/advert'),
            name: 'Advertisement',
            meta: { title: '广告管理', name: '98' }
          },
          {
            path: '/Link/index',
            component: () => import('@/views/market/seo/friendLink/friendLink'),
            name: 'friendLink',
            meta: { title: '友情链接', name: '98' }
          },
          {
            path: '/addLink',
            component: () => import('@/views/market/seo/friendLink/addLink'),
            name: 'addLink',
            meta: { title: '添加链接', guidePath: 'true', jumpPath: '/Link/index', name: '98' }
          },
          {
            path: '/updateLink',
            component: () => import('@/views/market/seo/friendLink/updateLink'),
            name: 'updateLink',
            meta: { title: '编辑链接', guidePath: 'true', jumpPath: '/Link/index', name: '98' }
          },
          {
            path: '/linkInfo',
            component: () => import('@/views/market/seo/friendLink/linkInfo'),
            name: 'linkInfo',
            meta: { title: '链接详情', guidePath: 'true', jumpPath: '/Link/index', name: '98' }
          }
          // {
          //   path: 'seo',
          //   component: () => import('@/views/market/seo/seo'),
          //   name: 'Seo',
          //   meta: { title: 'SEO设置' }
          // }
          // {
          //   path: 'sitemap',
          //   component: () => import('@/views/market/seo/sitemap'),
          //   name: 'sitemap',
          //   meta: { title: 'sitemap生成' }
          // },

        ]
      },
      // {
      //   path: 'contact',
      //   component: () => import('@/views/market/contact'),
      //   name: 'contact',
      //   meta: { title: '社交营销' }
      // },
      // {
      //   path: 'poster',
      //   component: () => import('@/views/market/poster'),
      //   name: 'poster',
      //   meta: { title: '营销海报' }
      // },
      {
        path: 'sem',
        component: () => import('@/views/market/sem/index'),
        name: 'sem',
        meta: { title: '统计分析', icon: 'icon-shujufenxi', name: '98' },
        children: [
          {
            path: '/SEM/baidu',
            component: () => import('@/views/market/sem/baidu'),
            name: 'baidu',
            meta: { title: '百度', name: '98' }
          },
          {
            path: '/SEM/google',
            // component: () => import('@/views/market/sem/google'),
            component: () => import('@/views/market/sem/google'),
            name: 'google',
            meta: { title: '谷歌', name: '98' }
          }
        ]
      }
    ]
  },
  {
    path: '/stats',
    component: Layout,
    redirect: '/stats/index',
    name: 'Stats',
    meta: { title: '招聘管理', icon: 'el-icon-s-help' },
    children: [
      {
        path: '/Job/index',
        name: 'Job',
        component: () => import('@/views/recruit/job'),
        meta: { title: '岗位管理', icon: 'icon-zhiweiguanli', name: '119' }
      },
      {
        path: '/JobCate/index',
        name: 'JobCate',
        component: () => import('@/views/recruit/jobCate'),
        meta: { title: '岗位分类', icon: 'icon-gangweifenlei', name: '119' }
      },
      {
        path: '/JobCity/index',
        name: 'JobCity',
        component: () => import('@/views/recruit/city'),
        meta: { title: '城市管理', icon: 'icon-chengshiguanli', name: '119' }
      }
    ]
  },
  // {
  //   path: '/stats',
  //   component: Layout,
  //   redirect: '/stats/index',
  //   name: 'Stats',
  //   meta: { title: '统计分析', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'index',
  //       component: () => import('@/views/stats/index'),
  //       meta: { title: '流量总览', icon: 'table' }
  //     },
  //     {
  //       path: 'source',
  //       name: 'source',
  //       component: () => import('@/views/stats/source'),
  //       meta: { title: '来源分析', icon: 'tree' }
  //     },
  //     {
  //       path: 'searchKeywords',
  //       name: 'searchKeywords',
  //       component: () => import('@/views/stats/searchKeywords'),
  //       meta: { title: '搜索关键词', icon: 'table' }
  //     },
  //     {
  //       path: 'visitor',
  //       name: 'visitor',
  //       component: () => import('@/views/stats/visitor'),
  //       meta: { title: '访客地区', icon: 'tree' }
  //     }
  //   ]
  // },

  // {
  //   path: 'external-link',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
  //       meta: { title: 'External Link', icon: 'link' }
  //     }
  //   ]
  // },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
